package com.zjw.concurrency.juc.lock;

public class RetreentLockExample {

    private static Object firstObj = new Object();
    private static Object secondObj = new Object();

    public static void main(String[] args) {

        new Thread(()->{
            synchronized (firstObj){
                System.out.println("firstObj1");
                try {
                    Thread.sleep(200);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                synchronized (secondObj){
                    System.out.println("secondObj1");
                }
            }
        }).start();

        new Thread(()->{
            synchronized (secondObj){
                System.out.println("secondObj2");
                synchronized (firstObj){
                    System.out.println("firstObj2");
                }
            }
        }).start();


    }
}
